<!DOCTYPE html>
<html>
<head>
  <meta charset='UTF-8'>
  <title>Document</title>
</head>
<style>
  .router-link-active{
    background-color: rgb(231, 18, 89);
  }
</style>
<body>
<div id="app">
  <router-link tag="button" to="/home">首页</router-link>
  <router-link tag="button" to="/news/2">新闻</router-link>
  <router-link tag="button" to="/about">关于</router-link>
  <hr>
  <router-view></router-view>
</div>
</body>
<script src="./vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.8/vue-router.js"></script>
<script>
const Home = {
  template:`
    <div>
      <h2>我是首页</h2>
    </div>
  `
}
const News = {
  template:`
    <div>
      <h2>我是新闻页</h2>
    </div>
  `
}
const About = {
  template:`
    <div>
      <h2>我是关于我们</h2>
    </div>
  `
}
const routes = [
  {
    path: '/home',
    component: Home
  },
  {
    path: '/news/:newsId',
    component: News
  },
  {
    path: '/about',
    component: About
  },
]
const router = new VueRouter({
  routes
})
const vm = new Vue({
  el: '#app',
  router
})
</script>
</html>